it seems that

Import Libraries

Import Dataset

EarthQuakes_in_Greece <- read.csv("EarthQuakes in Greece.csv")

Rename columns

earthquakes=EarthQuakes_in_Greece[,c(1,2,3,4,5,6,7,8)]
colnames(earthquakes)[6] <- "Lat"
colnames(earthquakes)[7] <- "Lon"
colnames(earthquakes)[8] <- "Richter"

Explore Variables

str(earthquakes)
## 'data.frame':    256655 obs. of  8 variables:
##  $ Year   : int  1901 1901 1901 1902 1902 1902 1902 1903 1903 1903 ...
##  $ Month  : int  9 10 12 4 7 8 11 3 3 5 ...
##  $ Date   : int  12 25 24 11 5 2 5 15 25 29 ...
##  $ Hours  : int  6 16 23 18 14 5 23 19 22 9 ...
##  $ Minutes: int  15 18 18 35 56 38 50 3 30 34 ...
##  $ Lat    : num  39 37 37.2 38.5 40.8 38.5 38.2 37.8 36 39.8 ...
##  $ Lon    : num  22.2 22.2 22.2 23.5 23.2 21.8 20.5 21.2 25 18.7 ...
##  $ Richter: num  5.6 5.4 5.8 5.8 6.6 5.6 5.5 5.7 5.5 6 ...

Change format of Date

earthquakes$DateFormatted <- as.Date(paste(earthquakes$Month, earthquakes$Date , earthquakes$Year), "%m %d %Y")

Point each earthquake in Greece map

newmap <- getMap(resolution = "low")
plot(newmap, xlim = c(18, 30), ylim = c(33, 42), asp = 1)
points(earthquakes$Lon, earthquakes$Lat, col = "red", cex = .6)

Count number of earthquakes for each year

sumYear <- earthquakes %>% 
  select(Year)  %>% 
  group_by(Year)  %>% 
  summarize(count = n())
datatable(sumYear)

Plot Number of earthquakes for each year

ggplot(sumYear, aes(x =  Year, y = count, colour = "yellow" , alpha = 1))  + 
  geom_point(colour = "blue")  + geom_line(colour = "black")

Plot Density

ggplot(earthquakes, aes(x  = Richter, 
                       fill = "red", 
                       alpha = 0.5))  + 
  geom_density(colour="blue")

Create dataframe for average magnitude per year

years <- unique(earthquakes$Year)
averageRichter <- 1:length(years)
for (i in years){
  temporary <- earthquakes %>% filter(Year==i)
  averageRichter[years==i] <- mean(temporary$Richter)
}
averageRichterPerYear<- data.frame('year' = years, 'averageRichter' = averageRichter)
averageRichterPerYear
##     year averageRichter
## 1   1901       5.600000
## 2   1902       5.875000
## 3   1903       6.114286
## 4   1904       5.966667
## 5   1905       5.853846
## 6   1906       5.600000
## 7   1907       6.200000
## 8   1908       5.566667
## 9   1909       5.737500
## 10  1910       5.600000
## 11  1911       5.630000
## 12  1912       5.626667
## 13  1913       5.500000
## 14  1914       5.483333
## 15  1915       5.754545
## 16  1916       5.460000
## 17  1917       5.344444
## 18  1918       5.238462
## 19  1919       5.346154
## 20  1920       5.250000
## 21  1921       5.285714
## 22  1922       5.442857
## 23  1923       5.230769
## 24  1924       5.133333
## 25  1925       5.207143
## 26  1926       5.608696
## 27  1927       5.385714
## 28  1928       5.446429
## 29  1929       5.050000
## 30  1930       5.607692
## 31  1931       5.407692
## 32  1932       5.472222
## 33  1933       5.364286
## 34  1934       5.450000
## 35  1935       5.781818
## 36  1936       5.166667
## 37  1937       5.225000
## 38  1938       5.392308
## 39  1939       5.350000
## 40  1940       5.550000
## 41  1941       5.350000
## 42  1942       5.400000
## 43  1943       5.273333
## 44  1944       5.654545
## 45  1945       5.340000
## 46  1946       5.471429
## 47  1947       5.453846
## 48  1948       5.517857
## 49  1949       5.436364
## 50  1950       5.012500
## 51  1951       5.208333
## 52  1952       5.065625
## 53  1953       5.040800
## 54  1954       4.918033
## 55  1955       4.966667
## 56  1956       5.000000
## 57  1957       5.041509
## 58  1958       4.892500
## 59  1959       4.885714
## 60  1960       4.865957
## 61  1961       4.866667
## 62  1962       4.968000
## 63  1963       4.797500
## 64  1964       4.968000
## 65  1965       4.043956
## 66  1966       3.955789
## 67  1967       3.678261
## 68  1968       3.622108
## 69  1969       3.716475
## 70  1970       3.543808
## 71  1971       3.514770
## 72  1972       3.525595
## 73  1973       3.470809
## 74  1974       3.360840
## 75  1975       3.369720
## 76  1976       3.441369
## 77  1977       3.382640
## 78  1978       3.620335
## 79  1979       3.617864
## 80  1980       3.454202
## 81  1981       3.615415
## 82  1982       3.386097
## 83  1983       3.557754
## 84  1984       3.430743
## 85  1985       3.438023
## 86  1986       3.355496
## 87  1987       3.467767
## 88  1988       3.519461
## 89  1989       3.339334
## 90  1990       3.258633
## 91  1991       3.247441
## 92  1992       3.336992
## 93  1993       3.326303
## 94  1994       3.446806
## 95  1995       3.178145
## 96  1996       3.407886
## 97  1997       3.344996
## 98  1998       3.308176
## 99  1999       3.261847
## 100 2000       3.295134
## 101 2001       3.328486
## 102 2002       3.283180
## 103 2003       3.306046
## 104 2004       3.117621
## 105 2005       3.157007
## 106 2006       3.200351
## 107 2007       3.228610
## 108 2008       3.096251
## 109 2009       2.928923
## 110 2010       2.825628
## 111 2011       1.881406
## 112 2012       1.725181
## 113 2013       1.830260
## 114 2014       1.897491
## 115 2015       1.887876
## 116 2016       1.928130
## 117 2017       2.057188
## 118 2018       1.993392

Plot Earthquake Average Magnitude by year

plt <- ggplot(averageRichterPerYear, aes(x = year, y = averageRichter)) +
  geom_line(aes(group=1), colour="#000045")+ geom_point(size=1, colour="#CC0000") + 
  xlab("Year") + ylab("Average Richter") +  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  ggtitle("Earthquake Average Magnitude by year ")
plt

Heat Map by frequency

heatMap <- ggplot() + borders(colour="gray", fill="gray")+ geom_point() +xlim(18, 30) +ylim(33, 42)
heatMapCompleted <- heatMap + geom_density2d(data = earthquakes, aes(x=earthquakes$Lon, y=earthquakes$Lat, color=Richter), size = 0.1) +
  stat_density2d(data = earthquakes, 
                 aes(x=earthquakes$Lon, y=earthquakes$Lat, fill = ..level.., alpha = ..level..),
                 size = 0.1, bins = 15, geom = "polygon") + scale_fill_gradient(low = "yellow", high = "red") + 
  scale_alpha(range = c(0, 1), guide = FALSE) + xlab("Longtitude") + ylab("Latitude") + 
  ggtitle("Earthquake Positions in Greece (1901-2018) (Heat Map by frequency)") + coord_fixed(ratio = 1)
heatMapCompleted
## Warning: Removed 61 rows containing non-finite values (stat_density2d).
## Warning: Computation failed in `stat_density2d()`:
## cannot allocate vector of size 195.8 Mb
## Warning: Removed 61 rows containing non-finite values (stat_density2d).

Map by position according to Magnitude

heatMapPos <- ggplot(data = earthquakes) + borders(colour="gray", fill="gray") +  xlim(18, 30) + ylim(33, 42)
heatmapPosCompleted <- heatMapPos + geom_point(aes(x=Lon, y=Lat, color=Richter), size=0.00001) + xlab("Longtitude") +
  ylab("Latitude") + ggtitle("Earthquake Positions from 1965 to 2016") + 
  scale_colour_gradient(low = "darkkhaki", high = "darkmagenta") + coord_fixed(ratio = 1)
heatmapPosCompleted
## Warning: Removed 61 rows containing missing values (geom_point).

Leaflet Plot for map clustering

earthquakes %>%
  leaflet() %>%
  addTiles() %>%
  addMarkers(lat=earthquakes$Lat, lng=earthquakes$Lon, clusterOptions = markerClusterOptions(),
             popup= paste("<br><strong>Richter: </strong>", earthquakes$Richter,
                          "<br><strong>Date: </strong>", earthquakes$DateFormatted
             ))